<template>
  <div class="dashboard-editor-container">
    <h1 style="line-height: 50px; text-align: center">每日总失败详情</h1>

    <el-table style="width: 85%; margin: 0 auto"
              v-loading="loading"
              :data="tableData">
      <el-table-column type="index"
                       width="50"></el-table-column>
      <el-table-column prop="createDate"
                       label="时间"
                       align="center"
                       :formatter="formatterTable"></el-table-column>
      <el-table-column prop="name"
                       label="姓名"
                       align="center"></el-table-column>
      <el-table-column prop="phone"
                       label="电话"
                       align="center"
                       :formatter="formatterTable"></el-table-column>
      <el-table-column prop="region"
                       label="地区"
                       align="center"
                       :formatter="formatterTable"></el-table-column>
      <el-table-column prop="start"
                       label="关注车型"
                       align="center"
                       :formatter="formatterTable"></el-table-column>
      <el-table-column prop="resultInfo"
                       label="线索状态"
                       align="center"
                       :formatter="formatterTable"></el-table-column>

    </el-table>
    <pagination v-if="total"
                :total="total"
                :page.sync="pageNum"
                :limit.sync="pageSize"
                @pagination="getSupplierDayDataPageList(row)" />
  </div>
</template>
<style>
.el-table .warning-row {
  background: oldlace;
  color: #f78989;
}
</style>
<script>
import { querySupplierDayTotalErr } from "@/api/supplier/supplier.js";
export default {
  data () {
    return {
      tableData: [],
      pageNum: 1,
      pageSize: 20,
      total: 0,
      loading: false,
      date: [],
      row: {}
    };
  },
  created () {
    this.row = this.$route.query
    this.getSupplierDayDataPageList(this.row)
  },
  methods: {
    formatterTable (row, column, cellValue, index) {
      if (!cellValue && column) {
        if (cellValue == "0") {
          cellValue = "0";
        } else {
          cellValue = "--";
        }
      }
      return cellValue;
    },
    getSupplierDayDataPageList (row) {
      let data = { pageNum: this.pageNum, pageSize: this.pageSize, activityId: row.activityId, begin: row.dayShow, end: row.dayShow }
      this.loading = true;
      querySupplierDayTotalErr(data).then(res => {
        this.total = res.data.total
        console.log('查看失败总数data', res);
        this.loading = false;
        if (res.code == 200) {
          this.$message({ showClose: true, message: res.msg || '操作成功', type: "success" });
          let responseData = JSON.parse(JSON.stringify(res.data.list))
          responseData.map(item => {
            item.createDate = item.createDate.split('T')[0]
            item.start = item.brandName + '-' + item.serialName
          })
          this.tableData = responseData
          console.log('tableData', this.tableData);
          console.log('responseData', responseData);
        } else {
          this.$message.info('网络错误')
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  // padding: 32px;
  // width: 90%;
  // margin: 0 auto;
  padding-top: 30px;
  position: relative;
  overflow: hidden;
}
</style>